package com.lanxin.generator.config;

import com.lanxin.generator.service.GeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 董伟豪
 * @Date: 2023/1/17 12:00
 */
@Configuration
@ConditionalOnClass(GeneratorService.class)
@EnableConfigurationProperties(DocAutoProperties.class)
public class DocAutoConfiguration {

    @Autowired
    private DocAutoProperties docAutoProperties;

    @Bean
    public GeneratorService generatorService(){
        GeneratorService generatorService = new GeneratorService();
        generatorService.createApi(docAutoProperties.getPathController(),
                docAutoProperties.getGeneratePosition(), docAutoProperties.getFileName());
        return generatorService;
    }
}
